function curry(fn) {
    return function curriedFn(...args) {
        console.log("curriedFn -> args", args)
        if(args.length < fn.length) {
            return function() {
                console.log(arguments)
                return curriedFn(...args.concat([...arguments]))
            }
        }
        return fn(...args)
    }
}

function add (a,b,c,d) {
    return a + b + c + d
}

console.log(curry(add)()(1,2)(3)(4))


